﻿#include "GameOver.h"
#include"GameButton.h"
#include"Game.h"
GameOver::GameOver(const int Score, const int x, const int y, QWidget* parent)
	:m_Score(Score)
{
	this->m_parent = parent;
	move(x, y);
	init();

	m_ButtonRestart = new GameButton("菜单按钮",parent);
	m_ButtonRestart->move(90, 580);
	m_ButtonRestart->setText("重新开始");
	m_ButtonRestart->show();
	QObject::connect(m_ButtonRestart, &QPushButton::clicked,(Game*)parent,&Game::CreateGameStart);

	
	m_ButtonOver = new GameButton("菜单按钮",parent);
	m_ButtonOver->move(90, 680);
	m_ButtonOver->setText("结束游戏");
	m_ButtonOver->show();
	QObject::connect(m_ButtonOver, &QPushButton::clicked, [=]() {parent->close(); });
}

void GameOver::init()
{
	addFrame("游戏结束", "正常");
}

void GameOver::update()
{
	
}

void GameOver::draw(QPainter* painter)
{
	getModel()["正常"].draw(painter, getModelRect().topLeft());
	m_NumFont.setPixelSize(32);
	painter->setPen(m_NumPen);
	painter->setFont(m_NumFont);

	QString Num = QString::number(m_Score);
	painter->drawText(QPoint(210,400), Num);
}

GameOver::~GameOver()
{
	delete m_ButtonOver;
	delete m_ButtonRestart;
}
